package com.zpf.mq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

@Component
public class MySender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() throws InterruptedException {
        for (int i = 0; i < 20; i++) {
            Thread.sleep(500);
            String context = "Time： " + LocalTime.now();
            System.out.println("Sender : " + context);
            this.rabbitTemplate.convertAndSend("queue0", context);
            this.rabbitTemplate.convertAndSend("queue1", context);
        }
    }

}